package ema2;

/**
 * @author Team TA's
 */


import java.io.Serializable;
import java.util.ArrayList;
//import java.util.HashMap;

//import ema2.Weekday.Day;

public class Schedule implements Serializable {
	
    private String period;
    //private HashMap<Day, ArrayList<Event>> schedule;
    private ArrayList<ArrayList<Event>> eventList;

    // CONSTRUCTORS
    
    // this constructor is solely for mock objects to use, hence protected
   /* protected Schedule(){
    	this.period = null;
    	this.schedule = null;
    }*/
    
    public Schedule(/*ArrayList<Day> week*/){
        this.setEventList(/*week*/);
        this.period = null;
    }
    
    public Schedule(/*ArrayList<Day> week, */String period){
    	this.setEventList(/*week*/);
    	this.period = period;
    }

    // GETTERS AND SETTERS
    
    public void setEventList(){
        this.eventList = new ArrayList<ArrayList<Event>>();

        for (int i=0; i<7; i++) {
            eventList.add(new ArrayList<Event>());
        }
    }

    public void setEventList(ArrayList<ArrayList<Event>> newEventList) {
        if (this.eventList == null) {
            setEventList();
        }
        else {
            this.eventList = newEventList;
        }
    }

    /*public void setSchedule(ArrayList<Day> newSchedule){
    	if (this.schedule == null){
    		this.schedule = new HashMap<Day, ArrayList<Event>>();
    	}
    	
    	// build schedule from given week, initialize empty event-arrays
        for (Day day : newSchedule){
        	this.schedule.put(day, new ArrayList<Event>());
        }
    }*/
    
        public ArrayList<ArrayList<Event>> getEventList(){
                return this.eventList;
	}

        public ArrayList<Event> getEventList(int day){
                return this.eventList.get(day);
	}

   /* public void setSchedule(HashMap<Day, ArrayList<Event>> newSchedule){
    	this.schedule = newSchedule;
    }
    
    public void setSchedule(Schedule newSchedule) {
		this.schedule = newSchedule.getEventList();
		this.period = newSchedule.getPeriod();
	}

    public HashMap<Day, ArrayList<Event>> getEventList(){
		return this.schedule;
	}*/
        public void setEventList(Schedule newSchedule) {
		this.eventList = newSchedule.getEventList();
		this.period = newSchedule.getPeriod();
	}

	public String getPeriod() {
		return period;
	}

	public void setPeriod(String period) {
		this.period = period;
	}
    
    // OTHER
	/*public void addEvent(Day eventDay, Event event) {
		if (!this.schedule.containsKey(eventDay)){ // if adding an event to non-existent date
			throw new IllegalArgumentException("No such date in the schedule");
		}
		this.schedule.get(eventDay).add(event);
	}*/
        public void addEvent(int eventDay, Event event) {

		this.eventList.get(eventDay).add(event);
	}

}
